#include "../include/head.h"
//连接服务器
int tcp_connect(char *ip, char *port)
{
    int fd_server = socket(AF_INET, SOCK_STREAM, 0);
    
    struct sockaddr_in serAddr;
    memset(&serAddr, 0, sizeof(serAddr));
    serAddr.sin_family = AF_INET;
    serAddr.sin_addr.s_addr = inet_addr(ip);
    serAddr.sin_port = htons(atoi(port));
    
    int ret =  connect(fd_server, (struct sockaddr*)&serAddr, sizeof(serAddr));
    ERROR_CHECK(ret, -1, "connect");
    
    return fd_server;
}

